package com.example.sharding.config;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import com.example.sharding.dao.NpGoodsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

@Component
public class ApplicationEventListener implements ApplicationListener {

    @Autowired
    NpGoodsMapper npGoodsMapper;
    @Override
    public void onApplicationEvent(ApplicationEvent applicationEvent) {
        if(applicationEvent instanceof ApplicationReadyEvent) {
            System.out.println("项目启动完成！！！！！！！！！！！！！");
            //HintManager.getInstance().setMasterRouteOnly();
            int count = npGoodsMapper.selectCount(new QueryWrapper<>());
            int count1 = npGoodsMapper.selectCount(new QueryWrapper<>());
            System.out.println("数据库查询结果:"+count);
            System.out.println("数据库查询结果:"+count1);
        }
    }
}
